<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增社保缴费管理')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
<style>
    .jltable{
        margin: auto;
    }
    .jltable th,td{
        min-height: 40px;
        min-width: 50px;
        border: 1px solid #eee;
        padding: 10px;
    }
</style>
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-sbjfgl-add">
        <h4 class="form-header h4">社保管理</h4>
        <table class="jltable">
            <tbody>
                <tr>
                    <td><label class="control-label">名称</label></td>
                    <td><input name="name" class="form-control" type="text"></td>
                    <td></td>
                    <td><label class="control-label is-required">适用对象</label></td>
                    <td>
                        <select  class="form-control" id="name_select" required></select>
                        <input name="sydx" class="form-control" type="hidden" required></td>
                </tr>
                <tr>
                    <td><label class="control-label is-required">开始月份</label></td>
                    <td>
                        <div class="input-group date">
                            <input name="ksyf" class="form-control" placeholder="yyyy-MM" type="text" required>
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </td>
                    <td></td>
                    <td><label class="control-label is-required">截至月份</label></td>
                    <td>
                        <div class="input-group date">
                            <input name="jzyf" class="form-control" placeholder="yyyy-MM" type="text" required>
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </td>
                </tr>

                <tr>
                    <td><label class="control-label">说明</label></td>
                    <td colspan="4"><textarea name="sm" class="form-control"></textarea></td>
                </tr>
                <tr>
                    <td><label class="control-label">相关文件</label></td>
                    <td colspan="4">
                        <input type="hidden" name="xgwj">
                        <div class="file-loading">
                            <input class="form-control file-upload" id="xgwj" name="file" type="file">
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>

        <h4 class="form-header h4" style="margin-top: 20px">养老保险</h4>
        <table class="jltable">
            <tbody>
                <tr>
                    <td><label class="control-label">养老保险基数</label></td>
                    <td><input name="ylbxjs" class="form-control" type="text"></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td><label class="control-label">养老个人比例（%）</label></td>
                    <td><input name="ylgrbl" class="form-control" type="text"></td>
                    <td><label class="control-label">养老单位比例（%）</label></td>
                    <td><input name="yldwbl" class="form-control" type="text"></td>
                </tr>
            </tbody>
        </table>

        <h4 class="form-header h4" style="margin-top: 20px">失业保险</h4>
        <table class="jltable">
            <tbody>
                <tr>
                    <td><label class="control-label">失业保险基数</label></td>
                    <td><input name="sybxjs" class="form-control" type="text"></td><td></td><td></td>
                </tr>
                <tr>
                    <td><label class="control-label">失业个人比例（%）</label></td>
                    <td><input name="sygrbl" class="form-control" type="text"></td>
                    <td><label class="control-label">失业单位比例（%）</label></td>
                    <td><input name="sydwbl" class="form-control" type="text"></td>
                </tr>
            </tbody>
        </table>
        <h4 class="form-header h4" style="margin-top: 20px">工伤保险</h4>
        <table class="jltable">
            <tbody>
                <tr>
                    <td><label class="control-label">工伤保险基数</label></td>
                    <td><input name="gsbxjs" class="form-control" type="text"></td><td></td><td></td>
                </tr>
                <tr>
                    <td><label class="control-label">工伤个人比例（%）</label></td>
                    <td><input name="gsgrbl" class="form-control" type="text"></td>
                    <td><label class="control-label">工伤单位比例（%）</label></td>
                    <td><input name="gsdwbl" class="form-control" type="text"></td>
                </tr>
            </tbody>
        </table>
        <h4 class="form-header h4" style="margin-top: 20px">医疗保险</h4>
        <table class="jltable">
            <tbody>
            <tr>
                <td><label class="control-label">医疗保险基数</label></td>
                <td><input name="ylbxjsYi" class="form-control" type="text"></td><td></td><td></td>
            </tr>
            <tr>
                <td><label class="control-label">医疗个人比例（%）</label></td>
                <td><input name="ylgrblYi" class="form-control" type="text"></td>
                <td><label class="control-label">医疗单位比例（%）</label></td>
                <td><input name="yldwblYi" class="form-control" type="text"></td>
            </tr>
            </tbody>
        </table>
        <h4 class="form-header h4" style="margin-top: 20px">生育保险</h4>
        <table class="jltable">
            <tbody>
                <tr>
                    <td><label class="control-label">生育保险基数</label></td>
                    <td><input name="sybxjsSheng" class="form-control" type="text"></td><td></td><td></td>
                </tr>
                <tr>
                    <td><label class="control-label">生育个人比例（%）</label></td>
                    <td><input name="sygrblSheng" class="form-control" type="text"></td>
                    <td><label class="control-label">生育单位比例（%）</label></td>
                    <td><input name="sydwblSheng" class="form-control" type="text"></td>
                </tr>
            </tbody>
        </table>
        <h4 class="form-header h4" style="margin-top: 20px">保险合计</h4>
        <table class="jltable">
            <tbody>
                <tr>
                    <td><label class="control-label">大病个人（元）</label></td>
                    <td><input name="dbgr" class="form-control" type="text"></td><td></td><td></td>
                </tr>
                <tr>
                    <td><label class="control-label">个人社保缴费（元）</label></td>
                    <td><input name="grsbjf" class="form-control" type="text"></td>
                    <td><label class="control-label">单位社保缴费（元）</label></td>
                    <td><input name="dwsbjf" class="form-control" type="text"></td>
                </tr>
            </tbody>
        </table>
        <h4 class="form-header h4" style="margin-top: 20px">公积金</h4>
        <table class="jltable">
            <tbody>
                <tr>
                    <td><label class="control-label">公积金基数</label></td>
                    <td><input name="gjjjs" class="form-control" type="text"></td>
                    <td></td><td></td>
                </tr>
                <tr>
                    <td><label class="control-label">公积金个人比例（%）</label></td>
                    <td><input name="gjjgrbl" class="form-control" type="text"></td>
                    <td><label class="control-label">公积金单位比例（%）</label></td>
                    <td><input name="gjjdwbl" class="form-control" type="text"></td>
                </tr>

                <tr>
                    <td><label class="control-label">公积金个人（元）</label></td>
                    <td><input name="gjjgr" class="form-control" type="text"></td>
                    <td><label class="control-label">公积金单位（元）</label></td>
                    <td><input name="gjjdw" class="form-control" type="text"></td>
                </tr>
            </tbody>
        </table>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<th:block th:include="include :: bootstrap-fileinput-js"/>
<th:block th:include="include :: select2-js" />
<script th:inline="javascript">
    var prefix = ctx + "lwpq/sbjfgl"
    $("#form-sbjfgl-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-sbjfgl-add').serialize());
        }
    }

            $("input[name='ksyf']").datetimepicker({
                format: "yyyy-mm",
                minView: "month",
                autoclose: true
            });

            $("input[name='jzyf']").datetimepicker({
                format: "yyyy-mm",
                minView: "month",
                autoclose: true
            });

            $(".file-upload").fileinput({
                uploadUrl: ctx + 'common/upload',
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })

    $(function (){
        function formatRepo(repo){
            return  repo.name || repo.text;
        }
        function formatRepoSelection(repo){
            return  repo.name || repo.text;
        }

        $('#name_select').select2({
            ajax:{
                url: ctx + 'lwpq/jl/list',
                type:'post',
                dataType:'json',
                data:function (params) {
                    let query = {
                        name:params.term,
                        zt:'',
                    }
                    return query;
                },
                processResults : function (data){
                    let res = new Array();
                    data.rows.forEach(value => {
                        res.push({
                            id : value.id,
                            text : value.name,
                            ob:value
                        })
                    })
                    return {
                        results : res
                    };
                },
                minimumInputLength : 1,
                maximumInputLength : 20,
                templateResult : formatRepo,
                templateSelection : formatRepoSelection,
            }
        })
        $('#name_select').on('select2:select', function (e) {
            // 处理业务
            let ob =  e.params.data.ob;
            $("input[name='sydx']").val(ob.name);
            $("input[name='name']").val(ob.name + '的社保');
        });
    })
</script>
</body>
</html>